package cn.czu.wyw.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @Author wyw
 * @Description
 * @Date 2021/3/15 15:16
 * @Version 1.0
 */
public class RabbitMqClientUtil {
    //要连接的mq主机，此处为本地连接
    private static final String HOST = "81.68.222.169";
    //mq的端口号默认为5672
    private static final int PORT = 5672;
    //访问mq的用户名
    private static final String USER_NAME = "admin";
    //用户密码
    private static final String PASSWORD = "admin";

    public static Connection getConnection() throws IOException, TimeoutException {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost(HOST);
        connectionFactory.setPort(PORT);
        connectionFactory.setPassword(PASSWORD);
        connectionFactory.setUsername(USER_NAME);
        return connectionFactory.newConnection();
    }
}
